IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IE_Stg_IE_SvcEntityStaffedPerson_Ctl_Exist]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[IE_Stg_IE_SvcEntityStaffedPerson_Ctl_Exist]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE dbo.IE_Stg_IE_SvcEntityStaffedPerson_Ctl_Exist 
AS
BEGIN

	SET NOCOUNT ON
	UPDATE Stg_IE_SvcEntityStaffedPerson_Ctl
	SET SvcEntityStaffedPersonMapId = MAP.Id,
	IsExist = 1
	FROM SvcEntity_AdmStaffedPerson_Map MAP
	WHERE MAP.SvcEntityId = Stg_IE_SvcEntityStaffedPerson_Ctl.SvcEntityId
	AND MAP.AdmPersonId = Stg_IE_SvcEntityStaffedPerson_Ctl.AdmPersonId

END

GO
